package com.saver.modules.sys.controller;

import com.saver.common.utils.PageUtils;
import com.saver.common.utils.R;
import com.saver.modules.sys.service.SysOperationLogService;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 系统日志
 *
 * @author yuxiaolong
 * @email 1005471232@qq.com
 * @date 2018年08月30日 下午11:22
 */
@RestController
@RequestMapping("/sys/log/operation")
public class SysOperationLogController {

    @Autowired
    private SysOperationLogService sysOperationLogService;

    /**
     * 分页
     *
     * @param map
     * @return
     */
    @GetMapping("/list")
    public R list(@RequestParam Map<String, Object> map) {
        Object sidx = map.get("sidx");
        Object order = map.get("order");
        if ("".equals(sidx) && "".equals(order)) {
            map.put("sidx", "create_date");
            map.put("order", "desc");
        }
        PageUtils pageUtils = sysOperationLogService.queryPage(map);
        return R.ok().put("page", pageUtils);
    }

    @GetMapping("/getParams/{id}")
    public R getParams(@PathVariable Long id) {
        return sysOperationLogService.getParams(id);
    }
}
